<template>
	<view>
		<nav-bar home :bgColor="['#CCCCCC','#CCCCCC']"  fontColor="#FFFFFF" title="农户基本信息"></nav-bar>
         <view style="width: 100%;height: 180rpx;">
         <!-- 	<view style="display: flex;width: 95%;margin: 0 auto;height: 50rpx;"> -->
         	<!-- 	<view style="color: gray;width: 95%;margin: 0 auto;">农户编号:{{this.form.id}}   </view> -->
         		<!-- <view class="tag">{{item.productType}}</view> -->
         	<!-- </view> -->
			<view style="color: gray;width: 95%;margin: 0 auto;">农户编号：{{this.form.id}}  </view>
			
         	<view style="color: gray;width: 95%;margin: 0 auto;">农户姓名：{{this.form.supplierName}} 乡镇：{{this.form.district}} </view>
         			
         	<view style="color: gray;width: 95%;margin: 0 auto;">养殖地址：{{this.form.address}} 电话：{{this.form.contactPhone}}
			</view>
         	<view style="display: flex;border-bottom: 1px solid #e3e3e3;">
         		<view class="tag2"><!-- 羊舍详情 --></view>
         	
         		
         	</view>
         	
         </view>
		<uni-card :is-shadow="true" title="羊舍管理">
			<!-- <v-tabs v-model="activeTab" @change="changeTab" :scroll="false" :bold="true" :tabs="tabs1"
				field="name"></v-tabs> -->
		<view class="productList"  v-if="activeTab == 0"><!-- show-summary sum-text="总价" -->
			<zb-table :columns="column0" :stripe="true" :fit="true"  show-summary sum-text="总计"
				:data="dataList0"></zb-table>
			
			</view>
			<!-- <view class="productList" v-for="item in dataList1" v-if="activeTab == 1"> -->
			<!-- <view class="productList" v-if="activeTab == 1">
			<zb-table :columns="column1" :stripe="true" :fit="true" 
				:data="dataList1"></zb-table>
			
			</view>
			 -->
				<!-- <view class="productList" v-if="activeTab == 2">
					<zb-table :columns="column2" :stripe="true" :fit="true" show-summary sum-text="总量"
						:data="dataList2"></zb-table>
					
				
					</view>
					<view class="productList"  v-if="activeTab == 3">
						<zb-table :columns="column4" :stripe="true" :fit="true" 
							:data="dataList3"></zb-table>
						
					
						</view> -->
		</uni-card>
	
		<!-- v-for="item in dataList4" show-summary sum-text="总数" -->
	<view class="productList"  >
		<uni-card>
			<uni-collapse>
				<uni-collapse-item title="羊只详情" :show-animation="true">
					<zb-table :columns="column3" :stripe="true" :fit="true" 
						:data="dataList4"></zb-table>
				</uni-collapse-item>
			</uni-collapse>
		</uni-card>
		</view>
		<!-- <uni-card>
			<uni-collapse>
				<uni-collapse-item title="还款试算 | 日利率0.014%（年化利率5.05%）" :show-animation="true">
					<view style="color: #a2a2a2;font-size: 25rpx;">资方费用 | 日利率0.014%（年化利率5.00%）</view>
					<view style="color: #a2a2a2;font-size: 25rpx;margin: 10rpx 0;">计费方式：等额本息</view>
					<zb-table :columns="column1" :stripe="true" :fit="true" show-summary sum-text="总计"
						:data="dataList1"></zb-table> -->
					<!-- <view style="color: #797979;font-size: 25rpx;margin: 20rpx 0;font-weight: bold;">平台费用</view> -->
				<!-- 	<view style="color: #a2a2a2;font-size: 25rpx;margin: 20rpx 0">以上仅为试算结果，以实际放款为准～</view>
				 -->	<!-- <view style="color: #040404;font-size: 30rpx;margin: 20rpx 0;font-weight: bold;">应还总额：￥10.09</view> -->
				<!-- </uni-collapse-item>
			</uni-collapse>
		</uni-card>
		<uni-card>
			<uni-collapse>
				<uni-collapse-item title="合同签署" :show-animation="true">
					<zb-table :columns="column3" :stripe="true" :fit="true"
						:data="dataList3"></zb-table>
				</uni-collapse-item>
			</uni-collapse>
		</uni-card>
		<uni-card>
			<uni-collapse>
				<uni-collapse-item title="缴纳费用" :show-animation="true">
					<zb-table :columns="column2" :stripe="true" :fit="true" show-summary sum-text="总价"
						:data="dataList2"></zb-table>
					<view style="color: #797979;font-size: 25rpx;margin: 20rpx 0;font-weight: bold;">订单状态：待付款</view>
					<button style="margin-left: 55%;" type="primary" size="mini">查看支付凭证图片</button>
				</uni-collapse-item>
			</uni-collapse>
		</uni-card> -->
		<view style="height: 60rpx;">
			<view class="bottomBox">
				<view class="buttonBox">
				<!-- 	<button class="button_fix mainColor" 
						size="default" type="warn">添加羊圈</button> -->
					<button class="button_fix" type="primary" size="default"  @click="handleAdd">添加羊舍</button>
					<button class="button_fix" type="primary"  size="default"  @click="handleAddSheep">添加羊只</button>
				
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				activeTab: 0,
				tbStatus: 0,
				tabs1: [/* {
						name: '羊舍详情',
						value: 1
					} *//* ,
					{
						name: '羊舍环境',
						value: 2
					},
					{
						name: '饮水和饲料',
						value: 3
					},
					{
						name: '管理员',
						value: 4
					} */
				],
				column0: [{
						type: 'index',
						label: '',
						align: 'center'
					},{
						name: 'sqmt',
						label: '羊舍面积',
						emptyString: '暂无数据',
						align: 'center'
					},
					{
						name: 'farmSqmt',
						label: '放养面积',
						emptyString: '暂无数据',
						align: 'center'
					},
					{
						name: 'sheepQtyLeft',
						label: '存栏',
						emptyString: '暂无数据',
						align: 'center'
					}/* ,
					{
						name: 'warehouseCode',
						label: '当日饲料投入总量',
						emptyString: '暂无数据',
						align: 'center'
					} */
				],
				dataList: [],
				dataList4: [],
				dataList0: [],
				column1: [{
						type: 'index',
						label: '监控序列号',
						align: 'center'
					},
					{
						name: 'temp',
						label: '温度',

						emptyString: '暂无数据',
						align: 'center'
					},
					{
						name: 'humid',
						label: '适度',
						emptyString: '暂无数据',
						align: 'center'
					},
					{
						name: 'ammoniaPercentage',
						label: '氨浓度',
						emptyString: '暂无数据',
						align: 'center'
					}
				],
				dataList1: [],
				column2: [{
						name: '',
						label: '',
						emptyString: '',
						align: 'center'
					},
					{
							name: 'waterVolume',
							label: '用水',
							emptyString: '暂无数据',
							align: 'center'
					},
					{
						name: 'todayFeed',
						label: '当天饲料（公斤）',
						emptyString: '暂无数据',
						align: 'center'
					}			
					
				],
				column4: [{
						name: 'waterVolume',
						label: '用水量（吨）',
						emptyString: '暂无数据',
						align: 'center'
					},
					{
						name: 'motherNo',
						label: '母亲编号',
						emptyString: '暂无数据',
						align: 'center'
					},			
					
				],
				dataList2: [],
				column3: [{
						name: 'sheepNo',
						label: '编号',
						emptyString: '暂无数据',
						align: 'center'
					},{
						name: 'motherNo',
						label: '母亲编号',
						emptyString: '暂无数据',
						align: 'center'
					},
					{
						name: 'fatherNo',
						label: '父亲编号',
						emptyString: '暂无数据',
						align: 'center'
					},
					{
						name: 'sex',
						label: '公母',
						emptyString: '暂无数据',
						align: 'center'
					},
					{
						name: 'sheepType',
						label: '类型',
						emptyString: '暂无数据',
						align: 'center'
					},
					{
						name: 'monthAge',
						label: '月龄',
						emptyString: '暂无数据',
						align: 'center'
					},
					{
						name: 'weight',
						label: '体重',
						emptyString: '暂无数据',
						align: 'center'
					},
					{
						name: 'castrate',
						label: '阉割',
						emptyString: '暂无数据',
						align: 'center'
					},					
					{
						name: 'vaccine',
						label: '疫苗',
						emptyString: '暂无数据',
						align: 'center'
					},
					{
						name: 'food',
						label: '食物',
						emptyString: '暂无数据',
						align: 'center'
					},
				/* 	{
						name: 'qualityEval',
						label: '品质评估',
						emptyString: '暂无数据',
						align: 'center'
					}, */
					{
						name: 'operation',
						type: 'operation',
						label: '操作',
						align: 'center',
						renders: [{
							name: '查看',
							//type: 'warn', // type 为custom的时候自定义按钮
							func: "detail"
						}]
					},
				],
				dataList3: [],
					form: {warehouseCode:""}
			}
		},
		onLoad(e) {
			 this.form = JSON.parse(e.id)
			 		 this.supplierNo = this.form.id
			 		
			 	//	this.loadData(supplierNo);
			 this.changeTab(0) ;
		},
		methods: {
			changeTab(e) { 
				this.activeTab = e
			  const suppilerNo = this.form.id
			  //alert(warehouseId);
				console.log(e)
				if (e == 0) {
					this.findSheepHouseConfig(suppilerNo)
					this.loadData(suppilerNo) 
				} else if (e == 1) {
					this.findEnvoirList(suppilerNo)
				} else if (e == 2) {
				/* 	const typeList = ['lamb'] */
					this.findWaterUseage(suppilerNo)
				} else if (e == 3) {
					//const proveStatusList = ['rejected']
					this.findWarehouseManagers(suppilerNo)
					
				} else {
				//	const proveStatusList = ['proved']
					//const typeList = ['ewe']
					//this.findSheepInforList(warehouseId)
			
				}
			},
			
			handleAddSheep() {
				 const suppilerNo = this.form.id
			  uni.navigateTo({
			    url: `/pages/resource/addSupplierSheep?suppilerNo=` + suppilerNo
			  });
			},
			handleAdd() {
				 const suppilerNo = this.form.id
			  uni.navigateTo({
			    url: `/pages/resource/addSupplierWarehouse?suppilerNo=` + suppilerNo
			  });
			},
			loadData(suppilerNo) {
				let opt = {
					url: 'basic/gzyySheepInfor/search',
					method: 'POST'
				};
				let params = {
				
					sheepBelongTo:  suppilerNo
				}
				this.$http.httpTokenRequest(opt, params).then(res => {
					let rangeList = res.data.data
					for (let i in rangeList) {
						
						// if(rangeList[i].creditLineUpto.toString().length > 7){
						// 	rangeList[i].creditLineUpto = rangeList[i].creditLineUpto.toString().slice(0,4)
						// }
						// else{
						// 	rangeList[i].creditLineUpto = rangeList[i].creditLineUpto.toString().slice(0,3)
						// }
					}
					this.dataList4 = rangeList
				})
			},
			detail() {
				alert(1);
				uni.navigateTo({
					url: '/pages/resource/sheepView?id='
				})
			},
			findWaterUseage(warehouseId) {
				let opt = {
					url: 'basic/gzyyWaterConsume/search',
					method: 'POST'
				};
				let params = {
				
					sheepHouseName:  warehouseId
				}
				this.$http.httpTokenRequest(opt, params).then(res => {
					let rangeList = res.data.data
					for (let i in rangeList) {
					
					}
					this.dataList2 = rangeList
					
				})
				},
			findSheepHouseConfig(suppilerNo) {
				let opt = {
					url: 'basic/warehouse/search',
					method: 'POST'
				};
				let params = {
				
					orgId:  suppilerNo
				}
				this.$http.httpTokenRequest(opt, params).then(res => {
					let rangeList = res.data.data
					for (let i in rangeList) {
					
					}
					this.dataList0 = rangeList
				
				})
				},
				findEnvoirList(warehouseId) {
					let opt = {
						url: 'basic/gzyyEnviorMonitor/search',
						method: 'POST'
					};
					let params = {
					
						warehouseId:  warehouseId
					}
					this.$http.httpTokenRequest(opt, params).then(res => {
						let rangeList = res.data.data
						for (let i in rangeList) {
						
						}
						this.dataList1 = rangeList
						
					})
					},
		}
	}
</script>

<style>
	.img {
		width: 100rpx;
		height: 100rpx;
		margin: 0 auto;
	}

	.top-title {
		text-align: center;
		font-size: 30rpx;
		font-weight: bold;
		margin: 10rpx;
	}

	.top-title1 {
		text-align: center;
		font-size: 28rpx;
		font-weight: bold;
		margin: 10rpx;
	}

	.content-margin {
		margin: 20rpx 0;
	}
	.bottomBox {
		position: fixed;
		width: 100%;
		bottom: 0;
		margin-bottom: 20rpx;
		
	}
	
	.buttonBox {
		width: 90%;
		margin: 0 auto;
		display: flex;
		justify-content: space-around;
	
		// margin-top: 200rpx;
	}
	
	.button_fix {
		width: 25%;
		height: 70rpx;
		// margin: 0 auto;
		color: #FFFFFF;
		/* background: #2749C8; */
		font-weight: bold;
		letter-spacing: 5rpx;
		font-size: 28rpx;
		line-height: 70rpx;
	
	}
	.mainColor{
		background: #2749C8;
	}
</style>